package br.com.obardavez.resources;

import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import br.com.obardavez.entity.Historia;
import br.com.obardavez.service.HistoriaService;

import com.google.inject.Inject;

@Path("/historia")
public class HistoriaResource {

	@Inject
	private HistoriaService historiaService;
	
	@POST
	@Produces(MediaType.APPLICATION_JSON)
	@Consumes(MediaType.APPLICATION_JSON)
	public Historia save(Historia historia) {
		try{
			historia = historiaService.saveOrUpdate(historia);
			return historia;
		}catch (Exception e) {
			e.printStackTrace();
			return null;
		}
    }

	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public List<Historia> getItensModerados(){
		return historiaService.getItensModerados();
	}
	
	
}
